package com.kgame5.xtank3d.app.view.gbook {
import kgame5.kgfw.gbook.GameBookComp;

import com.kgame5.xtank3d.app.AppEnum;
import com.kgame5.xtank3d.app.view.gbook.pagecover.PageCoverComp;
import com.kgame5.xtank3d.app.view.gbook.pagecover.PageCoverMediator;
import com.kgame5.xtank3d.app.view.gbook.pageloading.PageLoadingComp;
import com.kgame5.xtank3d.app.view.gbook.pageloading.PageLoadingMediator;
import com.kgame5.xtank3d.app.view.gbook.pageplay.PagePlayComp;
import com.kgame5.xtank3d.app.view.gbook.pageplay.PagePlayMediator;

import org.puremvc.as3.interfaces.INotification;
import org.puremvc.as3.patterns.mediator.Mediator;

import flash.display.MovieClip;

/**
 * @author kangkai
 * gameBook,包括一个个的gamePage
 */
public class GameBookMediator extends Mediator{
	public static const NAME:String="GameBookMediator";
	private var bookComp:GameBookComp;
	
	public function GameBookMediator(mc:MovieClip){
		super(NAME);
		
		bookComp=new GameBookComp();
		
		//----pageCover
		var coverPage:PageCoverComp=new PageCoverComp(mc.mc_pageCover);
		facade.registerMediator(new PageCoverMediator(coverPage));
		
		//----pageloading
		var loadingPage:PageLoadingComp=new PageLoadingComp(mc.mc_pageLoading);
		facade.registerMediator(new PageLoadingMediator(loadingPage));
		
		//----pagePlay
		var playPage:PagePlayComp=new PagePlayComp(mc.mc_pagePlay);
		facade.registerMediator(new PagePlayMediator(playPage));
		
		
		//
		bookComp.addPage(coverPage);
		bookComp.addPage(loadingPage);
		bookComp.addPage(playPage);
		
		//-
		bookComp.hide();
	}
	
	public override function listNotificationInterests() : Array {
		return [
			AppEnum.TURN_PAGE
		];
	}

	public override function handleNotification(e : INotification) : void {
		switch(e.getName()){
			case AppEnum.TURN_PAGE:
			var pageID:int=e.getBody() as int;
			bookComp.turnPage(pageID);
			break;
		}
	}
}//end of class
}
